/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ifpb.banco.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author Vanderlan
 */
@Entity
@Table(catalog = "", schema = "VANDERLAN")
@SequenceGenerator(name = "S_USUARIO_PK", sequenceName = "S_USUARIO_PK")
public class Usuario extends Identificavel{
    private static final long serialVersionUID = 1L;

    @Id
    @Basic(optional = false)
    @Column(name = "COD_USUARIO", nullable = false, precision = 0, scale = -127)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_USUARIO_PK")
    protected Long id;
    @Basic(optional = false)
    @Column(nullable = false, length = 10)
    private String login;
    @Basic(optional = false)
    @Column(nullable = false, length = 8)
    private String senha;
    @Basic(optional = false)
    @Column(name = "NIVEL_ACESSO", nullable = false, length = 3)
    private String nivelAcesso;
    @JoinColumn(name = "COD_FUNCIONARIO", referencedColumnName = "COD_FUNCIONARIO", nullable = false)
    @ManyToOne(optional = false)
    private Funcionario codFuncionario;

    public Usuario() {
    }

    public Usuario(Long codUsuario) {
        this.id = codUsuario;
    }

    public Usuario(Long codUsuario, String login, String senha, String nivelAcesso) {
        this.id = codUsuario;
        this.login = login;
        this.senha = senha;
        this.nivelAcesso = nivelAcesso;
    }

    public Long getCodUsuario() {
        return id;
    }

    public void setCodUsuario(Long codUsuario) {
        this.id = codUsuario;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }

    public String getNivelAcesso() {
        return nivelAcesso;
    }

    public void setNivelAcesso(String nivelAcesso) {
        this.nivelAcesso = nivelAcesso;
    }

    public Funcionario getCodFuncionario() {
        return codFuncionario;
    }

    public void setCodFuncionario(Funcionario codFuncionario) {
        this.codFuncionario = codFuncionario;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Usuario)) {
            return false;
        }
        Usuario other = (Usuario) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ifpb.banco.principal.entity.Usuario[ codUsuario=" + id + " ]";
    }
    
}
